﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.mainmenu {
    import reprise.ui.*;
    import flash.events.*;
    import reprise.external.*;
    import flash.display.*;
    import reprise.controls.*;
    import flash.utils.*;
    import net.wooga.pets.utils.*;
    import net.wooga.pets.external.*;

    public class FriendsScrollItem extends RadioButton {

        private var m_socialId:String;
        private var m_level:String;
        private var m_xpPoints:String;
        private var m_imageURL:String;
        private var m_name:String;
        private var m_imageDisplay:UIComponent;
        private var m_index:int;
        private var m_hasHiddenBird:Boolean;
        private var m_hasSymbolToHarvest:Boolean;
        private var m_symbolName:String;
        private var m_hiddenBird:UIComponent;
        private var m_symbol:UIComponent;

        private static const IMAGE_CACHE:Dictionary = new Dictionary();

        public function FriendsScrollItem(_arg1:String, _arg2:String, _arg3:String, _arg4:String, _arg5:String, _arg6:Boolean, _arg7:Boolean, _arg8:String){
            this.m_socialId = _arg1;
            this.m_level = _arg2;
            this.m_xpPoints = _arg3;
            this.m_imageURL = _arg4;
            this.m_name = _arg5;
            this.m_hasHiddenBird = _arg6;
            this.m_hasSymbolToHarvest = _arg7;
            this.m_symbolName = _arg8;
        }
        public function removeHiddenBird():void{
            this.m_hiddenBird.remove();
            this.m_hiddenBird = null;
        }
        public function removeSymbol():void{
            if (this.m_symbol){
                this.m_symbol.remove();
                this.m_symbol = null;
            };
        }
        public function get socialId():String{
            return (this.m_socialId);
        }
        public function get index():int{
            return (this.m_index);
        }
        public function set index(_arg1:int):void{
            this.m_index = _arg1;
        }
        override protected function initialize():void{
            addCSSClass("scrollItem");
            super.initialize();
        }
        override protected function createChildren():void{
            var _local4:MovieClip;
            var _local5:FacebookImageResource;
            addComponent("scrollItemBackground");
            addComponent("friendsBox");
            if (this.m_hasHiddenBird){
                this.m_hiddenBird = addComponent("hiddenBird");
            };
            if (this.m_hasSymbolToHarvest){
                _local4 = AssetsLibrary.getMovieClip((this.m_symbolName + "IconSmallBorder"));
                this.m_symbol = addComponent("symbolClipDisplay");
                this.m_symbol.addChild(_local4);
            };
            var _local1:Label = Label(addComponent("levelLabel", null, Label));
            _local1.setLabel(this.m_level);
            var _local2:Label = Label(addComponent("xpPointsLabel", null, Label));
            _local2.setLabel(this.m_xpPoints);
            this.m_imageDisplay = UIComponent(addComponent("imageDisplay"));
            if (IMAGE_CACHE[this.m_imageURL]){
                this.m_imageDisplay.addChild(IMAGE_CACHE[this.m_imageURL]);
            } else {
                if (this.m_imageURL){
                    _local5 = new FacebookImageResource(this.m_imageURL);
                    _local5.addEventListener(Event.COMPLETE, this.imageResourceComplete);
                    _local5.execute();
                    IMAGE_CACHE[this.m_imageURL] = _local5.loader();
                    this.m_imageDisplay.addChild(Loader(_local5.loader()));
                };
            };
            var _local3:Label = Label(addComponent("nameLabel", null, Label));
            _local3.setLabel(this.m_name);
            super.createChildren();
        }
        private function imageResourceComplete(_arg1:Event):void{
            var _local2:ImageResource = ImageResource(_arg1.target);
            _local2.removeEventListener(Event.COMPLETE, this.imageResourceComplete);
            this.m_imageDisplay.addCSSClass("hideLoader");
        }

    }
}//package net.wooga.pets.views.components.mainmenu 
